#include "Keyboard.h"


CKeyboard::CKeyboard(void)
{
}


CKeyboard::~CKeyboard(void)
{
}

void CKeyboard::PressKey(int key)
{
	keymap::iterator it = m_keys.find(key);

	if (it != m_keys.end())
	{
		it->second = true;
	}
	else
	{
		m_keys.insert( std::pair<int,bool>(key, true) );
	}
}

void CKeyboard::ReleaseKey(int key)
{
	keymap::iterator it = m_keys.find(key);

	if (it != m_keys.end())
	{
		it->second = false;
	}
}

std::vector<int> CKeyboard::GetKeysPressedDown()
{
	std::vector<int> ret;

	for (keymap::iterator it = m_keys.begin(); it != m_keys.end(); it++)
	{
		if (it->second == true)
		{
			ret.push_back(it->first);
		}
	}

	return ret;
}
